/*
循环数组，从数组对象里找到符合条件的对象，只有一条，找不到则返回undefined
 */
const arr = [
  { name: "张三", id: 1 },
  { name: "李四", id: 2 },
  { name: "李四", id: 3 },
];
const id = 1;
const obj = arr.find((v) => v.id === id);
console.log("obj", obj);
//consoel obj { name: '张三', id: 1 }
const id2 = 4;
const obj2 = arr.find((v) => v.id === id2);
console.log("obj2", obj2);
//consoel obj2 undefined
